/* 
 * File:   CheckerboardTexture.cpp
 * Author: neuma173
 * 
 * Created on May 3, 2011, 2:23 PM
 */

#include "CheckerboardTexture.h"

CheckerboardTexture::CheckerboardTexture(double checkSize, Vector3D color1, Vector3D color2){
    this->checkSize = checkSize;
    this->Color1 = color1;
    this->Color2 = color2;
}

CheckerboardTexture::CheckerboardTexture(const CheckerboardTexture& orig) {
    this->checkSize = orig.checkSize;
    this->Color1 = orig.Color1;
    this->Color2 = orig.Color2;
}

CheckerboardTexture::~CheckerboardTexture() {
}

Vector3D CheckerboardTexture::GetColorAt(const Vector3D& point)
{
    int xcheck = (int)floor(point[0]/checkSize); //ignore decimals
    int ycheck = (int)floor(point[1]/checkSize); //ignore decimals
    int zcheck = (int)floor(point[2]/checkSize); //ignore decimals

    int sum = xcheck + ycheck + zcheck; //if even, color1, else color 2

    if(sum%2 == 0)
    {
        return Color1;
    }
    else
    {
        return Color2;
    }
}

Vector3D CheckerboardTexture::GetNormalOffsetAt(const Vector3D& point)
{
    return Vector3D(0,0,0);
}